*Decentralization causes May 2023*
*DO FILE TO CREATE MARGINAL EFFECTS GRAPHs*
*SA Fig 2 where ethnic threat modifies gvuln*


#delimit ;
mixed raiapproved gvuln_lg ethnicthreat_lg gvuln_lgXethreat_lg raiapproved_lg langdif_lg area_lg logpopmil_lg jollyeuind_lg || countryno: || regionno:;

#delimit ;



 
*     ****************************************************************  *;
*              railevel  i.e. x2 = MV                               *;
*     ****************************************************************  *;
generate MV=((_n-1)/10);    

replace MV=. if _n>4000;

matrix b=e(b);
matrix list e(b);
matrix V=e(V);
matrix list e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];


scalar list b1 b2 b3 varb1 varb3 covb1b3;

gen conb=b1+b3*ethnicthreat_lg if _n<4000;



*     ****************************************************************  *;
*      These create conditional coefficients for b1 at MV,         *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*ethnicthreat_lg^2+2*covb1b3*ethnicthreat_lg)  if _n<4000;
set more off;
gen cont= conb/conse;


*     ****************************************************************  *;
*      This creates a conditional t                                   *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Generate confidence intervals at the 95% level                  *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=1.96*conse;
gen upper=conb+a;
gen lower=conb-a;
set textsize 100;


label variable conb "Marginal Effect of Governmental Vulnerability";
label variable upper "95% CI - upper bound";
label variable lower "95% CI - lower bound";
label variable ethnicthreat_lg "Ethnoterritorial Party Threat";



*     ****************************************************************  *;
*       Graph the effect of e threat on rai conditional on ethnicthreat_lg   *;
*                                          *;
*     ****************************************************************  *;
*this gives the full range*;



#delimit ;
gen where=-90;
gen pipe = "|";
egen tag_chge=tag(ethnicthreat_lg) if M45obs==1;

#delimit ;

sort ethnicthreat_lg;

*different ci*;
twoway (line conb ethnicthreat_lg, clpat(solid)) (line upper ethnicthreat_lg, clpat(shortdash)) (line lower ethnicthreat_lg, clpat(shortdash)), yline(0) ytitle("Conditional Coefficient of Governmental Vulnerability") legend(off), scatter where ethnicthreat_lg if tag_chge, plotr(m(b4)) ms(none) mlabcolor(gs5) mlabel (pipe) mlabpos(6);

clear;
